/*******************************************************************************
 * @file sensor.h
 * @brief  the sensor common function API
 *
 * @version 1.0.0
 *******************************************************************************
 * @license Refer License or other description Docs
 * @author  Felix
 ******************************************************************************/
#ifndef DEVS_SENSOR_H
#define DEVS_SENSOR_H

#include <stdint.h>
#include <stdbool.h>
#include "bsp_i2c.h"
//#include "hal_def.h"

struct sensor_func {
    bool flag;      /* Indicate if or not initialize */
    uint8_t idx;
    void ( *delay) (uint32_t ms);
    bool ( *read)  (BSP_Slave_Param *ptr, uint8_t *data, int len);
    bool ( *write) (BSP_Slave_Param *ptr, uint8_t *data, int len);
    void ( *pow_on) (uint8_t idx, bool enable);
    uint16_t ( *spi_rw) (uint8_t regs, uint8_t data);
};

/**
 * @brief    Init sensor module
 *
 * @param   sp      the pointer of sensor operation function
 *
 * @return  true if initialize success else false
 */
bool sensor_init(void *sp);

/**
 * @brief    Init sensor module
 *
 * @param addr  using addr for multiple devices
 * @param temp  the float temperature value of sensor
 * @param hum   the float humidity value of sensor
 *
 * @return true if read success else false
 */
bool sensor_read_temphumi(const uint8_t addr, float *temp, float *humi);

#endif
